//
//  PerTableView.m
//  operativeSide-2.0
//
//  Created by 马腾飞 on 16/12/19.
//  Copyright © 2016年 王春程. All rights reserved.
//

#import "PerTableView.h"
#import "PerCell.h"

@interface PerTableView()<UITableViewDelegate,UITableViewDataSource>



@end

static NSString *PerIdentifier = @"perCell";
@implementation PerTableView

- (instancetype)initWithFrame:(CGRect)frame style:(UITableViewStyle)style {
    self = [super initWithFrame:frame style:style];
    if (self) {
        self.backgroundColor = RGB(238, 238, 238);
        self.separatorStyle = UITableViewCellSeparatorStyleNone;
        self.dataSource = self;
        self.delegate = self;
        [self registerClass:[PerCell class] forCellReuseIdentifier:PerIdentifier];
    }
    return self;
}

#pragma mark - UITableViewDataSource
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return 5;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    PerCell *cell = [tableView dequeueReusableCellWithIdentifier:PerIdentifier forIndexPath:indexPath];
    [cell.iconView setImage:[UIImage imageNamed:self.iconArray[indexPath.row]]];
    cell.optionLabel.text = self.optionArray[indexPath.row];
    return cell;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    return 54;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    if ([self.perTableDelegate respondsToSelector:@selector(pushWithRow:)]) {
        [self.perTableDelegate pushWithRow:indexPath.row];
    }
}
@end
